using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace ObjectParser
{
	/// <summary>
	/// Summary description for GammaDialog.
	/// </summary>
	public class GammaDialog : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button butOK;
		public double UniversalGamma;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public GammaDialog(double uGamma)
		{
			InitializeComponent();

			UniversalGamma = uGamma;
			textBox1.Text = Convert.ToString(uGamma);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.butOK = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(8, 8);
			this.textBox1.Name = "textBox1";
			this.textBox1.TabIndex = 0;
			this.textBox1.Text = "1.0";
			// 
			// butOK
			// 
			this.butOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.butOK.Location = new System.Drawing.Point(120, 8);
			this.butOK.Name = "butOK";
			this.butOK.Size = new System.Drawing.Size(96, 23);
			this.butOK.TabIndex = 1;
			this.butOK.Text = "OK";
			this.butOK.Click += new System.EventHandler(this.butOK_Click);
			// 
			// GammaDialog
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(224, 38);
			this.Controls.Add(this.butOK);
			this.Controls.Add(this.textBox1);
			this.Name = "GammaDialog";
			this.Text = "Universal Gamma";
			this.ResumeLayout(false);

		}
		#endregion

		private void butOK_Click(object sender, System.EventArgs e)
		{
			try
			{
				double ug = Convert.ToDouble(textBox1.Text);
				if(ug > 0.0)
				{
					UniversalGamma = ug;
					this.DialogResult = DialogResult.OK;
					this.Close();
				}
				else 
				{
					this.DialogResult = DialogResult.None;
					MessageBox.Show("Please enter a valid number greater than zero.");
				}
			}
			catch
			{
				this.DialogResult = DialogResult.None;
				MessageBox.Show("Please enter a valid number greater than zero.");
			}
		}
	}
}
